home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 51 / Mac Magazin and MacEasy Magazine CD - Issue 51.iso / Software / Online / WebSentinel 2.0.4 / Extras / Scripting / sentinel_example.t < prev    next >
Text File  |  1998-08-25  |  3KB  |  89 lines

  1. <<
  2.     // Example template for interacting with WebSentinel
  3.     // Last modified: 8/25/1998
  4.  
  5.     // This simple example uses the functions defined in "sentinel_functions.t" 
  6.     // to communicate with WebSentinel.  Specifically, it duplicates the 
  7.     // "Lookup User" feature of WebSentinel Admin but in a web-based interface. 
  8.     // Although this feature is now an option in the WebSentinel 2.0 web-based 
  9.     // administration interface, this example may still be useful for understanding 
  10.     // how WebSentinel scripting works, and can be modified to build other custom 
  11.     // administration applications.
  12.  
  13.     // This example only uses a small number of the functions available when 
  14.     // communicating with WebSentinel.  See the Scripting folder of the 
  15.     // WebSentinel distribution for a complete list and description.  If you 
  16.     // have WebSentinel specific questions, you can also email 
  17.     // <websentinel-support@purity.com>.
  18.  
  19.     include "sentinel_functions.t";
  20.  
  21.     // There are two possible actions that we can take in this template. 
  22.     // First, if no variables are defined, we present a simple HTML form.  
  23.     // Otherwise, if the "target_id" variable is defined, we know the user 
  24.     // submitted the form and we use sentinel_LookupUser to find the user.
  25.     // Then, if the user is found, we redirect to the web-based admin of 
  26.     // WebSentinel to modify the user's information.
  27.  
  28.     if !defined (target_id) 
  29.     
  30.         // start off with some HTML for the page        
  31.         <<
  32.             <HTML>
  33.             <HEAD><TITLE>WebSentinel Lookup Example</TITLE>
  34.             <BODY>
  35.             
  36.             <FORM METHOD="GET" ACTION="sentinel_example.t">
  37.             
  38.             <P>Target: 
  39.             <SELECT NAME="target_id" SIZE="1">
  40.         >>
  41.             
  42.         // get a list of targets to build the popup menu
  43.         my_targets = sentinel_GetTargets();
  44.         repeat with one_target in my_targets
  45.             <<
  46.                 <OPTION VALUE="{one_target'1}">{one_target'2}
  47.             >>
  48.         end repeat;
  49.         
  50.         // finish off the HTML
  51.         <<
  52.             </SELECT>
  53.             <P>Username to lookup: 
  54.             <INPUT TYPE="TEXT" NAME="user" SIZE=30>        
  55.             <P>
  56.             <INPUT TYPE="SUBMIT" VALUE=" Lookup User ">
  57.             </FORM>
  58.             </BODY>
  59.             </HTML>            
  60.         >>
  61.     
  62.     else
  63.     
  64.         // find the user
  65.         user_id = sentinel_LookupUser (user, target_id);
  66.     
  67.         // if the user_id is 0, the user didn't exist
  68.         if user_id = 0
  69.         <<
  70.             <HTML>
  71.             <HEAD><TITLE>WebSentinel Lookup Example</TITLE>
  72.             <BODY>
  73.             
  74.             <P>Sorry, the user {user} didn't exist.
  75.             
  76.             </BODY>            
  77.             </HTML>
  78.         >>
  79.         else
  80.         
  81.             // the user was found, so now redirect to WebSentinel's web-based admin
  82.             // (note, redirect's really should have the full URL, includding the host name)
  83.             redirectClient ("/pi_admin.sentinel$modifyuser_form?target_id=" & target_id & "&user_id=" & user_id);
  84.         
  85.         end if;
  86.         
  87.     end if;
  88. >>
  89.